<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php
if (isset($_SESSION['lang']))
    require_once "./language_files/check-rebuttals_" . $_SESSION['lang'] . ".php";
else
    require_once "./language_files/check-rebuttals_en.php";
?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=9" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title><?php echo $lang['rebuttal_tital']; ?></title>
        <link href="style3.css" rel="stylesheet" type="text/css" />
        <?php include 'jquery.php'; ?>
        <script type="text/javascript" src="functions.js"></script>
        <script type="text/javascript">
            $(document).ready(function(){
                check_top();
            });
        </script>
    </head>
    <body>
        <form action ="check-rebuttals.php" method ="get">
            <?php
            require_once "functions.php";
// Connect to the database
            if (isset($_GET['paper_id']) && isset($_GET['conference_id'])) {
                $id = $_GET['paper_id'];
                $confID = $_GET['conference_id'];
                $confName = get_conference_name($confID);
                echo"
	</br><span class=breadcrumbs><a href='subscriberConferencePage.php?conference_id={$confID}'>" . $confName . "</a>" . " > " . $lang['view'] . " </span> </br>";
// Query for a list of all status of papers
                $result = mysql_query("SELECT DISTINCT p.conference_id, p.paper_id, p.paper_title, a.rebuttal_text, c.text
                FROM paper p
                INNER JOIN comment c
                ON (c.version_id = p.paper_id)
                INNER JOIN a_rebuttal_paper a
                ON (c.comment_id = a.comment_id)
                WHERE p.paper_id = {$id} AND p.conference_id = $confID") or die(mysql_error());
// Check if it was successfull
                if ($result) {
                    $num_results = mysql_num_rows($result);
                    // Make sure there are some rows in the database
                    if ($num_results == 0) {
                        ?><p align="center"><?php echo $lang['message_1']; ?></p><?php
        } else {
            // Print the top of a table
                        ?><table id="table">
                            <tr>
                                <td><b><?php echo $lang['comment']; ?></b></td>
                                <td><b><?php echo $lang['author_rebuttal']; ?></b></td>
                                <td><b><?php echo $lang['meta_reveiews']; ?></b></td>
                            </tr>
            <?php
            while ($row = mysql_fetch_assoc($result)) {
                ?>
                                <tr>
                                    <td><?php echo $row['text']; ?></td>
                                    <td><?php echo $row['rebuttal_text']; ?></td>
                                    <td><a href="requestMetaReviewers.php?paper_id={$row['paper_id']}&amp;conference_id={$confID}"><?php echo $lang['RequestMeta_reveiews']; ?></a></td>
                                </tr><?php
            }

            //author: aya.elmobayad. added links for requesting meta reviewers that pass the paper id
            //of the paper to the next page.
            // Close table
            echo '</table>';
        }
    } else {
        // if connetion to database failed
        echo $lang['error_1'];
    }
// Close the mysql connection
    mysql_close();
} else {
    echo $lang['error_2'];
}
?>
        </form>
    </body>
</html>